@extends('admin.common.base-master')

@section('html-head')
    <link href="{{url('css/admin/pagenum.css')}}" rel="stylesheet" />
@endsection

@section('html-body')
    <!-- content start -->
    <div id="content">
        <!-- cur-position start -->
        <div id="cur-position">
            <span class="tit">当前位置：</span>
            <a href="#">用户管理</a>
        </div>
        <!-- cur-position end -->

        <!--filter-box start-->
        <div class="filter-box clearfix">
            <div class="fl">
                <span class="search-bd">
                {{--<form id="form_promoter">--}}
                    <input type="text" class="search-ipt" name="pro_name" placeholder="用户昵称" value="" id="nickname">
                    <input class="search-smt" type="button">
                    {{--</form>--}}
            </span>
            </div>
        </div>
        <!--filter-box end-->

        <div class="table-box">
            <table class="table">
                <thead>
                <tr>
                    <th>ID</th>
                    <th>头像</th>
                    <th>昵称</th>
                    <th>地区</th>
                    <th>创建时间</th>
                    <th>账户状态</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody id="fansinfo">
                @if(count($users) > 0)
                    @foreach($users as $user)
                        <tr>
                            <td>{{$user->id}}</td>
                            <td class="account-td" style="width: 20px;">
                                <span class="photo">
                                    <img src="{{route("Api.File.showImageById",["id"=>$user->userInfo->photo_id])}}" alt="">
                                </span>
                            </td>
                            <td>
                                <div class="info-box">
                                    <p>
                                        <span class="icon icon-rzh"></span>
                                        <span class="name">@if($user->userInfo){{$user->userInfo->nickname}}@endif</span>
                                    </p>
                                </div>
                            </td>
                            <td>@if($user->userInfo){{$user->userInfo->province}}{{$user->userInfo->city}}{{$user->userInfo->area}}@endif</td>
                            <td>{{$user->created_at}}</td>
                            <td>@if((int)$user->status == 0)<span class="color3">待审核</span> @elseif((int)$user->status == 1)<span class="color4">正常</span>@endif</td>
                            <td>@if((int)$user->status == 0)<a id='change_status' class="btnLump btnLump1" href="javascript:;" data-status="{{$user->status}}" data-id="{{$user->id}}">通过审核</a>@else<a id="change_status" href="javascript:;" data-status="{{$user->status}}" data-id="{{$user->id}}">锁定</a>@endif</td>
                        </tr>
                    @endforeach
                @endif
                </tbody>
            </table>
            <?php echo $users->render(); ?>
        </div>
    </div>
    <!-- content end -->
    <script>
        $(function(){
            $(document).on('click','#change_status',function(){
                var status = $(this).attr('data-status');
                var id= $(this).attr('data-id');

//                alert(id+status);
                $.ajax({
                    url:'{{route("Api.Admin.sys.changeUserStatus")}}',
                    type:'post',
                    dataType:'json',
                    data:{status:status,id:id},
                    success:function(obj){
                        if(obj.level == "success"){
                            noty({type:obj.level,text:obj.message,timeout:600});
                            window.location.href='{{route('Admin.Home.userList')}}';
                        }else{
                            noty({type:obj.level,text:obj.message,timeout:600});
                        }
                    },
                    error:function(obj){
                        console.log(obj);
                    }

                });

            });
        });
    </script>
@endsection